package com.dt.demo_goodservice.controller;

import com.dt.demo_goodservice.pojo.Goods;
import com.dt.demo_goodservice.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class GoodsController {
    @Autowired
    private GoodService goodService;

    @GetMapping("/findGoods")
    public Goods seachGoodsById(int id)throws Exception{
//        if(id==1){
//            TimeUnit.SECONDS.sleep(5);
//        }
       //TimeUnit.SECONDS.sleep(5);//线程暂停可以触发熔断机制
        return goodService.findGoodsById(id);
    }

}
